package cn.com.dcsgo.utils;

import lombok.Data;

/**
 * 响应体
 *
 * @author Dcsgo
 * @since 2025/3/8 15:40
 */
@Data
public class R<T> {
    private int code = 200;
    private boolean flag = true;
    private T data;

    public static <T> R<T> fail(T data) {
        R<T> r = new R<>();
        r.setCode(500);
        r.setFlag(false);
        r.setData(data);
        return r;
    }

    public static <T> R<T> fail() {
        R<T> r = new R<>();
        r.setCode(500);
        r.setFlag(false);
        r.setData(null);
        return r;
    }

    public static <T> R<T> success(T data) {
        R<T> r = new R<>();
        r.setData(data);
        return r;
    }

    public static <T> R<T> success() {
        R<T> r = new R<>();
        r.setData(null);
        return r;
    }
}
